// 商品服务实现类
package com.heima.service.impl;

import com.heima.entity.SeckillGoods;
import com.heima.mapper.SeckillGoodsMapper;
import com.heima.service.GoodsService;
import com.heima.vo.GoodsVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private SeckillGoodsMapper seckillGoodsMapper;

    public List<GoodsVo> listGoodsVo() {
        // 这里应该查询所有参与秒杀的商品，为了简化实现，省略具体实现
        return null;
    }

    public GoodsVo getGoodsVoByGoodsId(long goodsId) {
        SeckillGoods seckillGoods = seckillGoodsMapper.getSeckillGoodsByGoodsId(goodsId);
        GoodsVo goodsVo = new GoodsVo();
        // 设置属性值
        BeanUtils.copyProperties(seckillGoods, goodsVo);

        return goodsVo;
    }
}
